import React from 'react';

interface ButtonProps {
  children: React.ReactNode;
  variant?: 'default' | 'secondary' | 'ghost' | 'destructive';
  size?: 'sm' | 'default' | 'lg' | 'icon';
  className?: string;
  onClick?: () => void;
  disabled?: boolean;
  type?: 'button' | 'submit' | 'reset';
}

const Button: React.FC<ButtonProps> = ({
  children,
  variant = 'default',
  size = 'default',
  className = '',
  onClick,
  disabled = false,
  type = 'button',
}) => {
  // 基础样式
  let baseClasses = 'inline-flex items-center justify-center font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none';
  
  // 变体样式
  const variantClasses = {
    default: 'bg-primary text-white hover:bg-primary/90',
    secondary: 'bg-slate-100 text-slate-800 hover:bg-slate-200 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700',
    ghost: 'hover:bg-slate-100 dark:hover:bg-slate-800',
    destructive: 'bg-destructive text-white hover:bg-destructive/90',
  };
  
  // 尺寸样式
  const sizeClasses = {
    sm: 'h-8 px-2 text-sm',
    default: 'h-9 px-4 text-sm',
    lg: 'h-10 px-6 text-base',
    icon: 'h-9 w-9 p-0',
  };
  
  // 圆角样式
  const roundedClasses = 'rounded-md';
  
  // 组合所有样式
  const classes = `${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]} ${roundedClasses} ${className}`;

  return (
    <button
      type={type}
      className={classes}
      onClick={onClick}
      disabled={disabled}
    >
      {children}
    </button>
  );
};

export { Button };